<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<style type="text/css">

		</style>
		<link rel="stylesheet" type="text/css" href="css/reg-login.css" />
		<script src="js/jquery-1.11.3.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/Cookie.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/ajax.js" type="text/javascript" charset="utf-8"></script>
	</head>

	<body>
		<div class="wraper1">
			<div class="header-a">
				<a href="index.html">
					<div class="logo"></div>
				</a>
			</div>
		</div>
		<!--header结束-->
		
			
		<div id="dBody">
		      <!--	<img src="http://www.mqjj.com/templets/spy/images/bg3.jpg"/>-->
		</div>
		<!--footer-->
		<div class="footer-b">
			<div class="anquan" title="安全交易认证">
				<img src="img/anquanrenz.jpg" />
				<span>网上交易保障中心</span>

			</div>
			<ul class="footer-list">
				<li id="spacial">
					<a href="javascript:;">使用条款</a>
				</li>
				<li>
					<a href="javascript:;">暖岛APP</a>
				</li>
				<li>
					<a href="javascript:;">友情链接</a>
				</li>
			</ul>
			<p>Nuandao.com 北京暖岛网络信息科技有限公司 © 2011-2016 All rights reserved 京ICP备13034710号-1 | 京公网安备11010102001819号 | 营业执照编号：102489641
			</p>
			<div class="work m-hidden">
				周一至周五9:30-18:00
			</div>
		</div>
		<!--footer-b-->
		<!--登录注册div-->
		<div id="my-content">
			<div class="mycontent-left">
				<h2>中国具有创造力的设计电商</h2>
				<div class="login-subtitle">
					<span>让最好的一切发生</span>
				</div>
				<div class="login_welcome">
					注册就送<strong><span class="J_nd-welcome">100</span>元</strong>现金券
				</div>
				<img src="http://jc.nuandaojs.com/Public/images/login-cover-0808.gif" alt="welcome to nuandao">
				
				<div class="login_promise">每日全球设计新品&nbsp;2折起包邮+赠券特卖</div>
			</div>
			<div class="my-content-right">
				<div class="login-main_title" id="J_login-main_title">
					<a href="javascript:;" data-btntext="登录暖岛" class="checked">登录</a>&nbsp;|&nbsp;<a href="javascript:;" data-btntext="注册暖岛">注册</a>
				</div>
				<!--form-->
				<!--<form method="post" action="/public/lazyentrance" id="loginform" class="login-account" autocomplete="off">
					<input class="login-account_field login-account_email" type="email" name="email" id="uemail" placeholder="邮件地址" autocomplete="off">
					<input class="login-account_field login-account_passwd" type="password" name="password" id="upassword" placeholder="暖岛密码" autocomplete="off">
					<div class="login-account_getpasswd"><a href="/public/forgetpwd">忘记密码</a></div><a href="javascript:;" class="btn login-account_go" id="tologin-btn">登录暖岛</a><div class="login-account_error" id="text-error1"></div>
					<input type="hidden" name="remember" id="remember" value="1" title="下次自动登录"><input type="hidden" name="uagreeterms" id="uagreeterms" value="1" title="同意暖岛服务条款">
				</form>-->
				<form action="" method="post" class="login-account">
					<input type="email" name="email" id="" placeholder="邮件地址" autocomplete="on" class="login-account_field login-account_email"/>
					<input type="password" placeholder="暖岛密码" autocomplete="off" name="password" class="login-account_field login-account_passwd"/>
					<div class="login-account_error" id="text-error1"></div>
					<div class="login-account_getpasswd">
						<a href="javascript:;">忘记密码</a>
					</div>
					<a href="javascript:;" class="btn login-account_go" id="tologin-btn">登录暖岛</a>
				</form>
				<!--其他登录方式-->
				<div class="login-other">
					<div class="login-other_title">
						其他登岛方式：
					</div>
					<a href="javascript:;" class="login-other_wb loginSNS" data-sns="weibo_url">
						微博登岛
					</a>
					<div class="login-another_title">
						<a id="J_loginOtherSNS" href="javascript:;">更多&nbsp;▼</a>
					</div>
					<div class="login-another_main" id="J_loginOtherSNSMain" <!--style="display: none;-->">
						<a href="javascript:;" class="login-another_qq loginSNS" data-sns="qqh_url">QQ登岛</a>
						<a href="javascript:;" class="login-another_rr loginSNS" data-sns="renren_url">人人登岛</a>
					</div>
				</div><!--其他登陆方式-->
				<div class="login_declare">
					注册登录暖岛后，您已同意<a href="/public/tc">用户使用条款</a>
				</div>
				<a href="javascript:;" id="J_shao2-helper" class="shao2-helper">下载<span>APP</span></a>
			</div>
		</div>
	</body>

	<script type="text/javascript">
		$(document).ready(function(){
			$('#J_login-main_title a').click(function(){
				$('#J_login-main_title a').toggleClass('checked');
//				console.log($(this).attr('data-btntext'));
				$('#tologin-btn').html($(this).attr('data-btntext'))
			})
			
			//检测注册时，格式是否正确
			/*else if(userVal && !pdVal){
					$('#text-error1').html('请填写密码')
				}*/
			$('#tologin-btn').click(function(){
				let userVal=$('.login-account_email').val();
				let pdVal=$('.login-account_passwd').val();
				if($('#tologin-btn').html() == '注册暖岛'){
					judgment(function(){
						var regAPI=` http://jx.xuzhixiang.top/ap/api/reg.php?username=${userVal}&password=${pdVal}`
						ajax(regAPI,function(res){
							console.log(res)
							if(res.code==1){
								//alert(res.msg);
								location.href=`index.html`
							}
						})
					})
					
				}else{
					//登录暖岛
					judgment(function(){
						var loginAPI=` http://jx.xuzhixiang.top/ap/api/login.php?username=${userVal}&password=${pdVal}`
						ajax(loginAPI,function(res){
							console.log(res)
							if(res.code==1){
								//tmp.innerHTML=res.msg
								console.log(res.data.id)
								//保存信息
								//token 令牌
								setCookie('userEmail',res.data.username,30)
								setCookie('uid',res.data.id,30)
								
								//$('#text-error1').html('登录成功')
								location.href=`index.html`;
							}else{
								$('#text-error1').html(res.msg)
							}
							
						})
					})
					
				}
				
				
				
				
				
				
				//封装判断函数
				function judgment(cbfn){
				if(!userVal){
					$('#text-error1').html('请填写邮箱')
				}else{
					//邮箱填写了
					
					//判断邮箱填写是否正确
					if(/^\w+[-+.]*\w*@([a-z0-9A-Z\u2E80-\u9FFF]-?)+(\.\w{2,6})+/.test(userVal)){
						//邮箱填写正确
						//接下来判断密码
						if(!pdVal){
							//没写密码
							$('#text-error1').html('请填写密码')
						}else{
							//$('#text-error1').html('写了密码')
							//直接跳转到首页
							//location.href=`index.html`
							//全部都正确
							cbfn();
						}
					}else{
						//邮箱格式错误
						$('#text-error1').html('邮箱格式有误')
					}
				}
			}
			})
			
			
			
			
			
			
			
			
			
			
			
		})
		
		
	</script>
</html>